package com.hspedu.newData.dmsxl.滑动窗口;

import org.junit.Test;

/**
 * @Author: yh
 * @description:
 * @CreateTime: 2025-05-06
 * @Version: 1.0
 */

public class LC485最大连续1的个数 {

    public int findMaxConsecutiveOnes(int[] nums) {

        int max = 0;
        int count = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 0){
                max = Math.max(max,count);
                count = 0;
                continue;
            }
            count++;
        }
        return Math.max(max,count);

    }

    @Test
    public void test() {
        // 测试代码

        findMaxConsecutiveOnes(new int[]{1,1,0,1,1,1});
        findMaxConsecutiveOnes(new int[]{1,0,1,1,0,1});
        System.out.println("000000");
    }

}
